//
//  ShowMore_TBV_Cell.m
//  WWAVPlayer
//
//  Created by dllo on 15/10/29.
//  Copyright © 2015年 LZY. All rights reserved.
//

#import "ShowMore_TBV_Cell.h"
#import "ShowMore_CLV_DetailCell.h"
#import "Blocks.h"
#import <UIImageView+WebCache.h>
@implementation ShowMore_TBV_Cell

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.myLabel = [[UILabel alloc]initWithFrame:CGRectMake(25 * W, 5 *H, 345 * W, 30 * H)];
        //        self.myLabel.backgroundColor = [UIColor greenColor];
        self.myLabel.textColor = [UIColor colorWithRed:0.3694 green:0.3694 blue:0.3694 alpha:1.0];
        // self.myLabel.backgroundColor = [UIColor colorWithRed:0.9514 green:0.5909 blue:0.8633 alpha:1.0];
        [self.myLabel setFont:[UIFont fontWithName:@"Verdana-Bold" size:15*W]];
        self.myLabel.numberOfLines = 2;
        [self addSubview:self.myLabel];
        
        self.myView = [[UILabel alloc]initWithFrame:CGRectMake(10 * W, 5 * H, 10 * W, 30 *H)];
        self.myView.backgroundColor = [UIColor orangeColor];
        
        // self.myLabel.backgroundColor = [UIColor colorWithRed:0.9514 green:0.5909 blue:0.8633 alpha:1.0];
        
        
        [self addSubview:self.myView];
        
        UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
        flowLayout.itemSize = CGSizeMake(172*W, 150*H);
        flowLayout.minimumInteritemSpacing = 7*W ;
        flowLayout.sectionInset = UIEdgeInsetsMake(10*W, 10*H, 10*W, 10*H);
        self.myCollectionVew = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, 335*W, 300*H) collectionViewLayout:flowLayout];
        
        self.myCollectionVew.backgroundColor = [UIColor whiteColor];
        self.myCollectionVew.scrollEnabled = NO;
        self.myCollectionVew.dataSource = self;
        self.myCollectionVew.delegate = self;
        self.myCollectionVew.backgroundColor = [UIColor colorWithWhite:0.937 alpha:1.000];
        [self.myCollectionVew registerClass:[ShowMore_CLV_DetailCell class] forCellWithReuseIdentifier:@"reuse2"];
        [self addSubview:self.myCollectionVew];
        
    }
    return self;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.myCollectionVew.frame = CGRectMake(0, 40*H, self.bounds.size.width, self.bounds.size.height-40*H);
    
}


-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    
    return self.contentsArr.count;
}


-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    ShowMore_CLV_DetailCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse2" forIndexPath:indexPath];
    
    NSDictionary *dic = [self.contentsArr objectAtIndex:indexPath.row];
    [cell.myimgeView1 sd_setImageWithURL:[NSURL URLWithString:[dic objectForKey:@"still"]]];
    cell.myLabel1.text = [dic objectForKey:@"name"];
    return cell;
    
}



-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *dic =  [self.contentsArr objectAtIndex:indexPath.item];
    [self.delegate passToCollectionWithIdNum:[dic objectForKey:@"mid"]];
}



@end
